package com.yangjun.utils;

import java.io.IOException;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;

import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.yangjun.common.timetask.ScheduledTasks;


public class HttpUtils {
	private static Logger logger = Logger.getLogger(HttpUtils.class);  

	//设置超时时间
	private static RequestConfig requestConfig = RequestConfig
			.custom()
			.setSocketTimeout(15000)
			.setConnectTimeout(15000)
			.setConnectionRequestTimeout(15000)
			.build();
	private static HttpUtils instance = null;
	
	public static HttpUtils getInstance(){
		if(instance == null){
			instance = new HttpUtils();
		}
		return instance;
	}
	public String sendHttpGet(String url){
		HttpGet httpGet = new HttpGet(url);
		return sendHttpGet(httpGet);
	}
	
	private String sendHttpGet(HttpGet httpGet){
		String responseStr = null;
		CloseableHttpResponse response = null;
		CloseableHttpClient httpClient = null;
		HttpEntity entity = null;  
		
		try{
			//创建httpClient实例
			httpClient = HttpClients.createDefault();
			httpGet.setConfig(requestConfig);
			response = httpClient.execute(httpGet);
			entity = response.getEntity();
			responseStr = EntityUtils.toString(entity);
		}catch(Exception e){
			e.printStackTrace();
		}finally {
				try {
					if(response!=null){
						response.close();
					}
					 if (httpClient != null) {  
	                    httpClient.close();  
					 }  
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			
		}
		return responseStr;
	}
	/**
     * A thread that performs a GET.
     */
    static class GetThread extends Thread implements Callable<Map<String,String>> {

        private final CloseableHttpClient httpClient;
        private final HttpContext context;
        private final HttpGet httpget;
        private final int id;
        private String searchKeyword;
        private String siteId;
        private String result = null;
        private Map<String,String> resultMap = Maps.newHashMap();
        private String total = null;

        public GetThread(CloseableHttpClient httpClient, HttpGet httpget, int id,String searchKeyword,String siteId) {
            this.httpClient = httpClient;
            this.context = new BasicHttpContext();
            this.httpget = httpget;
            this.id = id;
            this.siteId = siteId;
            this.searchKeyword = searchKeyword;
        }

        
        @Override
        public void run() {
            try {
                CloseableHttpResponse response = httpClient.execute(httpget, context);
                try {
                    HttpEntity entity = response.getEntity();
                    if (entity != null) {
                        result = EntityUtils.toString(entity);
                		JSONObject searchObj =  JSON.parseObject(result);
                		total = searchObj.getJSONObject("Data").getInteger("total").toString();
                		resultMap.put("siteId", siteId);
                		resultMap.put("searchkeyword", searchKeyword);
                		resultMap.put("results", total);
                    }
                } finally {
                    response.close();
                }
            } catch (Exception e) {
            }
        }
        @Override
        public Map<String,String> call() throws Exception {
            return resultMap;
        }
    }
    public static  List<Map<String,String>> threadGet(List<Map<String,Object>> reqList) {
        System.out.println("get共执行" + reqList.size() + "个请求");
        List<Map<String,String>> resultList = Lists.newArrayList();
        PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
        //设置线程数最大100,如果超过100为请求个数
        cm.setMaxTotal(reqList.size() > 100 ? reqList.size() : 100);
        CloseableHttpClient httpclient = HttpClients.custom()
                .setConnectionManager(cm)
                .build();
        try {
            GetThread[] getThreads = new GetThread[reqList.size()];
            for (int i = 0; i < reqList.size(); i++) {
                String searchKeyword = reqList.get(i).get("SEARCH_KEYWORD").toString();
                String siteId = reqList.get(i).get("SITE_ID").toString();
                HttpGet get = new HttpGet("http://app.360kad.com/search/default?pageText="+URLEncoder.encode(searchKeyword,"utf-8"));
                getThreads[i] = new GetThread(httpclient, get, i + 1,searchKeyword,siteId);
            }
            //执行线程
            for (GetThread gt : getThreads) {
                gt.start();
            }
            //设置所有线程执行完毕之后再执行后续代码
            for (GetThread gt : getThreads) {
                gt.join();
            }
            for (int i = 0; i < reqList.size(); i++) {
            	resultList.add(getThreads[i].call());
            }

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                httpclient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return resultList;
    }

//	public static void main(String[] args) {
		//{"Code":0,"Message":"搜索成功","Data":{"total":17,"pageSize":12,"pageIndex":1,"channel":[{"ChannelInfo":{"ChannelName":"药品","ChannelCode":"142610","ChannelCodeDesc":"药品","FactChannelCode":"142610_药品","HaveCount":6},"SecChannel":[{"ChannelName":"西药","ChannelCode":"13103010","ChannelCodeDesc":"西药","FactChannelCode":"13103010_西药","HaveCount":6}]}],"filter":[{"FilterCode":"BrandCode","FilterName":"品牌","FilterDesc":"品牌","Items":[{"FilterCode":"87","FilterName":"汤臣倍健"},{"FilterCode":"116","FilterName":"养生堂"},{"FilterCode":"1228542","FilterName":"白云山"},{"FilterCode":"1010144","FilterName":"康富来"},{"FilterCode":"1010311","FilterName":"同洲"},{"FilterCode":"1010462","FilterName":"美澳健"},{"FilterCode":"1228025","FilterName":"来益"},{"FilterCode":"1228736","FilterName":"修正"},{"FilterCode":"1229288","FilterName":"双鲸"},{"FilterCode":"1229390","FilterName":"康恩贝"},{"FilterCode":"860","FilterName":"葵花药业"}]},{"FilterCode":"WebChannelCodeSplit","FilterName":"类型","FilterDesc":"商品分类","Items":[{"FilterCode":"app2203","FilterName":"维生素E"},{"FilterCode":"app15528801","FilterName":"美白祛斑"},{"FilterCode":"app15527881","FilterName":"补充维生素"},{"FilterCode":"app15539331","FilterName":"维生素E"},{"FilterCode":"app15539221","FilterName":"美白"},{"FilterCode":"app15539241","FilterName":"祛斑"},{"FilterCode":"app15528871","FilterName":"番茄红素"},{"FilterCode":"app15538071","FilterName":"补充维生素"},{"FilterCode":"app15538141","FilterName":"复合维生素"},{"FilterCode":"app15538221","FilterName":"提高免疫力"},{"FilterCode":"app15538311","FilterName":"祛斑祛痘"},{"FilterCode":"app15539721","FilterName":"提高免疫力"},{"FilterCode":"app15539751","FilterName":"维生素"}]},{"FilterCode":"DrugForm","FilterName":"剂型","FilterDesc":"剂型","Items":[{"FilterCode":"285010","FilterName":"胶囊"},{"FilterCode":"285010","FilterName":"胶囊剂"}]},{"FilterCode":"ShiYiRenQun","FilterName":"适宜人群","FilterDesc":"适宜人群","Items":[{"FilterCode":"285400","FilterName":"女性"},{"FilterCode":"285400","FilterName":"成人"}]},{"FilterCode":"AppSalePrice","FilterName":"价格","FilterDesc":"价格","Items":[{"FilterCode":"0000","FilterName":"0-100"},{"FilterCode":"0000","FilterName":"100-200"},{"FilterCode":"0000","FilterName":"200-500"}]}],"products":[{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f3D%2f55%2fCgAgEFeGDhOAQ1H7AAHOXV9Jusw280.jpg_180x180.jpg","Title":"修正 金奥力牌大豆异黄酮胶囊维E软胶囊","CommonName":"金奥力牌大豆异黄酮胶囊维E软胶囊","Adv":"【10月特惠】低至：60元/盒！增加骨密度，适用于中老年女性，修正大品牌，质量有保障！","Spec":"500mg*60粒","Price_Market":78.0,"Price":69.0,"Keyword":"修正|大豆异黄酮|维E","PromotionLevel":1,"ProducerName":"修正 金奥力牌大豆异黄酮胶囊维E软胶囊 500mg*60粒","Unit":"","ItemID":"107504","GeneralId":"107504","rxotc":"otc","Domain":"http://m.360kad.com","SaleCount":0,"Popularity":0,"IconImg":""},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f1D%2f08%2fCgAgEVadnRqAYyiSAAAgANyBIe479.jpeg","Title":"来益 维生素E软胶囊（天然型）","CommonName":"维生素E软胶囊（天然型）","Adv":"丹桂十月：低至20.5元/盒起！具有抗氧化、抗衰老、增强卵巢功能，可用于心脑血管疾病及习惯性流产、不孕症的辅助治疗。","Spec":"100mg*30粒","Price_Market":28.0,"Price":21.0,"Keyword":"维生素E软胶囊|心脑血管疾病|习惯性流产|不孕症|避孕流产|流产","PromotionLevel":1,"ProducerName":"来益 维生素E软胶囊（天然型） 100mg*30粒","Unit":"","ItemID":"1283","GeneralId":"1283","rxotc":"otc","Domain":"http://m.360kad.com","SaleCount":136,"Popularity":9,"IconImg":""},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f1D%2fC3%2fCgAgEFaoet6ARsA3AAAgAOK5Qfs01.jpeg","Title":"来益 维生素E软胶囊（天然型）","CommonName":"维生素E软胶囊（天然型）","Adv":"丹桂十月：低至35.5元/盒 ，可用于心、脑血管疾病及习惯性流产、不孕症的辅助治疗。","Spec":"100mg*60粒","Price_Market":46.0,"Price":35.5,"Keyword":"维生素E软胶囊|流产|不孕|1111|11.11|双十一|避孕流产","PromotionLevel":1,"ProducerName":"来益 维生素E软胶囊（天然型） 100mg*60粒","Unit":"","ItemID":"40896","GeneralId":"40896","rxotc":"otc","Domain":"http://m.360kad.com","SaleCount":738,"Popularity":41,"IconImg":""},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f1F%2fE4%2fCgAgEFbT_MSAetm8AAHJrKj7I4g329.jpg_180x180.jpg","Title":"星群 维生素E软胶囊（滴剂）","CommonName":"维生素E软胶囊（滴剂）","Adv":"丹桂十月：低至18元/盒起！维生素E具有抗氧化、抗衰老、增强卵巢功能，可用于心、脑血管疾病及习惯性流产、不孕症的辅助治疗。","Spec":"100mg*60粒","Price_Market":23.0,"Price":18.0,"Keyword":"维生素E软胶囊|心脑血管疾病|习惯性流产|不孕症|避孕流产|流产|备孕|准备怀孕|不怀孕|不孕不育|不育|调经促孕|排卵试纸|不孕|影响怀孕","PromotionLevel":1,"ProducerName":"星群 维生素E软胶囊（滴剂） 100mg*60粒","Unit":"","ItemID":"9998156","GeneralId":"9998156","rxotc":"otc","Domain":"http://m.360kad.com","SaleCount":172,"Popularity":6,"IconImg":""},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f08%2f26%2fCgAgEVWKRyGAcTgcAAAlPWxJYMg839.jpg","Title":"双鲸 维生素E软胶囊（天然型）","CommonName":"维生素E软胶囊（天然型）","Adv":"丹桂十月：低至33元/盒，用于心、脑血管疾病及习惯性流产，不孕症的辅助治疗。","Spec":"100mg*60粒","Price_Market":45.0,"Price":33.0,"Keyword":"双鲸|维生素E软胶囊（天然型）|不孕症|抗衰老|保护皮肤","PromotionLevel":1,"ProducerName":"双鲸 维生素E软胶囊（天然型） 100mg*60粒","Unit":"","ItemID":"70355","GeneralId":"70355","rxotc":"otc","Domain":"http://m.360kad.com","SaleCount":79,"Popularity":14,"IconImg":""},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f1D%2f9C%2fCgAgEVal03yAE7FQAAAgAJDIEaU47.jpeg","Title":"舍灵 维生素E软胶囊(天然型)","CommonName":"维生素E软胶囊(天然型)","Adv":"丹桂十月：低至27元/盒！，可抗衰老、保护皮肤、还能增加卵巢功能，防止习惯性流产。用于心、脑血管疾病及不孕症的辅助治疗。","Spec":"100mg*15粒*2板","Price_Market":35.0,"Price":27.0,"Keyword":"维生素E软胶囊|心脑血管疾病|习惯性流产|不孕症","PromotionLevel":1,"ProducerName":"舍灵 维生素E软胶囊(天然型) 100mg*30粒","Unit":"","ItemID":"39898","GeneralId":"39898","rxotc":"otc","Domain":"http://m.360kad.com","SaleCount":0,"Popularity":0,"IconImg":""},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f1F%2f9D%2fCgAgEVbQYNaAO-AyAAHaiZgLqt8640.jpg_180x180.jpg","Title":"来益牌 天然维生素E软胶囊","CommonName":"天然维生素E软胶囊","Adv":"【10月聚惠】低至100元/瓶！本品保健功能是抗氧化、祛黄褐斑。","Spec":"0.4g*160粒","Price_Market":156.0,"Price":108.0,"Keyword":"来益牌|天然维生素E软胶囊","PromotionLevel":1,"ProducerName":"来益牌 天然维生素E软胶囊 0.4g*160粒","Unit":"","ItemID":"74865","GeneralId":"74865","rxotc":"otc","Domain":"http://m.360kad.com","SaleCount":47,"Popularity":34,"IconImg":""},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f1F%2fA6%2fCgAgEVbQa-aATWlzAAF8VuEQQIM712.jpg_180x180.jpg","Title":"康恩贝 天然维生素E软胶囊","CommonName":"天然维生素E软胶囊","Adv":"【十月特惠】低至52元/盒！维生素E可祛斑延缓衰老，满200元还可获价值56元皇后 片仔癀保湿滋润蜜 90ml哦，片仔癀老品牌，滋润水密葆青春！","Spec":"0.45g*120粒","Price_Market":73.0,"Price":55.3,"Keyword":"康恩贝|天然维生素E软胶囊|康恩贝 天然维生素E软胶囊","PromotionLevel":1,"ProducerName":"康恩贝 天然维生素E软胶囊  0.45g*120粒","Unit":"","ItemID":"1010170240","GeneralId":"1010170240","rxotc":"otc","Domain":"http://m.360kad.com","SaleCount":1,"Popularity":7,"IconImg":""},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f1F%2f9D%2fCgAgEFbQXuSAKQu7AAFR2X8XPUA481.jpg_180x180.jpg","Title":"养生堂 天然维生素E软胶囊","CommonName":"天然维生素E软胶囊","Adv":"【今日秒杀】仅需109元/瓶，去黄褐斑，美容养颜只需每日一片！满200元还可获价值56元皇后 片仔癀保湿滋润蜜哦，片仔癀老品牌，滋润水密葆青春！","Spec":"160粒","Price_Market":148.0,"Price":118.0,"Keyword":"养生堂天然维生素E软胶囊|养生堂|天然维生素E|维生素E|1111|11.11|双十一","PromotionLevel":4,"ProducerName":"养生堂 天然维生素E软胶囊 160粒","Unit":"","ItemID":"41282","GeneralId":"41282","rxotc":"otc","Domain":"http://m.360kad.com","SaleCount":285,"Popularity":31,"IconImg":""},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f3E%2fBE%2fCgAgEVeN2xqAPJOFAAGvQ3fDwqY560.jpg_180x180.jpg","Title":"康富来 天然维生素E软胶囊","CommonName":"康富来天然维生素E软胶囊","Adv":"【十月特惠·秋季滋补礼】原价168，限时特惠79，送康富来 血尔口服液 76ml*2。【女为悦己者容】美如冠玉，倾国倾城~天然VE，是爱美人士之选！","Spec":"0.25g*160粒","Price_Market":0,"Price":168.0,"Keyword":"康富来|天然维生素E软胶囊|维生素E","PromotionLevel":1,"ProducerName":"康富来 天然维生素E软胶囊 0.25g*160粒","Unit":"","ItemID":"6634","GeneralId":"6634","rxotc":"otc","Domain":"http://m.360kad.com","SaleCount":0,"Popularity":0,"IconImg":""},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f3D%2fD5%2fCgAgEVeIwM-AI1QPAAHR_vt0bAA391.jpg_180x180.jpg","Title":"汤臣倍健 天然维生素E软胶囊（促销装）","CommonName":"天然维生素E软胶囊（促销装）","Adv":"【十月特惠】低至100元/盒，120粒，一天不到1块钱，超值实惠！","Spec":"500mg/粒*60粒*2瓶","Price_Market":156.0,"Price":118.0,"Keyword":"汤臣倍健|天然维生素E软胶囊|皮肤粗糙|缺乏弹性|色斑多|内分泌失调|月经不调|心烦失眠","PromotionLevel":1,"ProducerName":"汤臣倍健 天然维生素E软胶囊（促销装） 500mg/粒*60粒*2瓶","Unit":"","ItemID":"1010239980","GeneralId":"1010239980","rxotc":"otc","Domain":"http://m.360kad.com","SaleCount":1,"Popularity":8,"IconImg":""},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f3D%2fB3%2fCgAgEVeISHqAS_p1AAGLqgbxu8k826.jpg_180x180.jpg","Title":"汤臣倍健 番茄红素维生素E软胶囊","CommonName":"番茄红素维生素E软胶囊","Adv":"【本月活动】低至230元起！番茄红素具有抗氧化的作用，常用于前列腺疾病的预防以及保健。","Spec":"500mg/粒*60粒/瓶","Price_Market":321.6,"Price":242.0,"Keyword":"汤臣倍健|番茄红素维生素E软胶囊","PromotionLevel":1,"ProducerName":"汤臣倍健 番茄红素维生素E软胶囊 500mg/粒*60粒/瓶","Unit":"","ItemID":"79645","GeneralId":"79645","rxotc":"otc","Domain":"http://m.360kad.com","SaleCount":20,"Popularity":31,"IconImg":""}]}}
		//{"filter":[{"FilterDesc":"品牌","Items":[{"FilterCode":"87","FilterName":"汤臣倍健"},{"FilterCode":"116","FilterName":"养生堂"},{"FilterCode":"1228542","FilterName":"白云山"},{"FilterCode":"1010144","FilterName":"康富来"},{"FilterCode":"1010311","FilterName":"同洲"},{"FilterCode":"1010462","FilterName":"美澳健"},{"FilterCode":"1228025","FilterName":"来益"},{"FilterCode":"1228736","FilterName":"修正"},{"FilterCode":"1229288","FilterName":"双鲸"},{"FilterCode":"1229390","FilterName":"康恩贝"},{"FilterCode":"860","FilterName":"葵花药业"}],"FilterCode":"BrandCode","FilterName":"品牌"},{"FilterDesc":"商品分类","Items":[{"FilterCode":"app2203","FilterName":"维生素E"},{"FilterCode":"app15528801","FilterName":"美白祛斑"},{"FilterCode":"app15527881","FilterName":"补充维生素"},{"FilterCode":"app15539331","FilterName":"维生素E"},{"FilterCode":"app15539221","FilterName":"美白"},{"FilterCode":"app15539241","FilterName":"祛斑"},{"FilterCode":"app15528871","FilterName":"番茄红素"},{"FilterCode":"app15538071","FilterName":"补充维生素"},{"FilterCode":"app15538141","FilterName":"复合维生素"},{"FilterCode":"app15538221","FilterName":"提高免疫力"},{"FilterCode":"app15538311","FilterName":"祛斑祛痘"},{"FilterCode":"app15539721","FilterName":"提高免疫力"},{"FilterCode":"app15539751","FilterName":"维生素"}],"FilterCode":"WebChannelCodeSplit","FilterName":"类型"},{"FilterDesc":"剂型","Items":[{"FilterCode":"285010","FilterName":"胶囊"},{"FilterCode":"285010","FilterName":"胶囊剂"}],"FilterCode":"DrugForm","FilterName":"剂型"},{"FilterDesc":"适宜人群","Items":[{"FilterCode":"285400","FilterName":"女性"},{"FilterCode":"285400","FilterName":"成人"}],"FilterCode":"ShiYiRenQun","FilterName":"适宜人群"},{"FilterDesc":"价格","Items":[{"FilterCode":"0000","FilterName":"0-100"},{"FilterCode":"0000","FilterName":"100-200"},{"FilterCode":"0000","FilterName":"200-500"}],"FilterCode":"AppSalePrice","FilterName":"价格"}],"total":17,"pageIndex":1,"channel":[{"SecChannel":[{"ChannelName":"西药","ChannelCodeDesc":"西药","ChannelCode":"13103010","HaveCount":6,"FactChannelCode":"13103010_西药"}],"ChannelInfo":{"ChannelName":"药品","ChannelCodeDesc":"药品","ChannelCode":"142610","HaveCount":6,"FactChannelCode":"142610_药品"}}],"pageSize":12,"products":[{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f3D%2f55%2fCgAgEFeGDhOAQ1H7AAHOXV9Jusw280.jpg_180x180.jpg","Keyword":"修正|大豆异黄酮|维E","rxotc":"otc","Popularity":0,"SaleCount":0,"Title":"修正 金奥力牌大豆异黄酮胶囊维E软胶囊","PromotionLevel":1,"Unit":"","ItemID":"107504","GeneralId":"107504","IconImg":"","Adv":"【10月特惠】低至：60元/盒！增加骨密度，适用于中老年女性，修正大品牌，质量有保障！","Price":69.0,"ProducerName":"修正 金奥力牌大豆异黄酮胶囊维E软胶囊 500mg*60粒","Price_Market":78.0,"Spec":"500mg*60粒","Domain":"http://m.360kad.com","CommonName":"金奥力牌大豆异黄酮胶囊维E软胶囊"},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f1D%2f08%2fCgAgEVadnRqAYyiSAAAgANyBIe479.jpeg","Keyword":"维生素E软胶囊|心脑血管疾病|习惯性流产|不孕症|避孕流产|流产","rxotc":"otc","Popularity":9,"SaleCount":136,"Title":"来益 维生素E软胶囊（天然型）","PromotionLevel":1,"Unit":"","ItemID":"1283","GeneralId":"1283","IconImg":"","Adv":"丹桂十月：低至20.5元/盒起！具有抗氧化、抗衰老、增强卵巢功能，可用于心脑血管疾病及习惯性流产、不孕症的辅助治疗。","Price":21.0,"ProducerName":"来益 维生素E软胶囊（天然型） 100mg*30粒","Price_Market":28.0,"Spec":"100mg*30粒","Domain":"http://m.360kad.com","CommonName":"维生素E软胶囊（天然型）"},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f1D%2fC3%2fCgAgEFaoet6ARsA3AAAgAOK5Qfs01.jpeg","Keyword":"维生素E软胶囊|流产|不孕|1111|11.11|双十一|避孕流产","rxotc":"otc","Popularity":41,"SaleCount":738,"Title":"来益 维生素E软胶囊（天然型）","PromotionLevel":1,"Unit":"","ItemID":"40896","GeneralId":"40896","IconImg":"","Adv":"丹桂十月：低至35.5元/盒 ，可用于心、脑血管疾病及习惯性流产、不孕症的辅助治疗。","Price":35.5,"ProducerName":"来益 维生素E软胶囊（天然型） 100mg*60粒","Price_Market":46.0,"Spec":"100mg*60粒","Domain":"http://m.360kad.com","CommonName":"维生素E软胶囊（天然型）"},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f1F%2fE4%2fCgAgEFbT_MSAetm8AAHJrKj7I4g329.jpg_180x180.jpg","Keyword":"维生素E软胶囊|心脑血管疾病|习惯性流产|不孕症|避孕流产|流产|备孕|准备怀孕|不怀孕|不孕不育|不育|调经促孕|排卵试纸|不孕|影响怀孕","rxotc":"otc","Popularity":6,"SaleCount":172,"Title":"星群 维生素E软胶囊（滴剂）","PromotionLevel":1,"Unit":"","ItemID":"9998156","GeneralId":"9998156","IconImg":"","Adv":"丹桂十月：低至18元/盒起！维生素E具有抗氧化、抗衰老、增强卵巢功能，可用于心、脑血管疾病及习惯性流产、不孕症的辅助治疗。","Price":18.0,"ProducerName":"星群 维生素E软胶囊（滴剂） 100mg*60粒","Price_Market":23.0,"Spec":"100mg*60粒","Domain":"http://m.360kad.com","CommonName":"维生素E软胶囊（滴剂）"},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f08%2f26%2fCgAgEVWKRyGAcTgcAAAlPWxJYMg839.jpg","Keyword":"双鲸|维生素E软胶囊（天然型）|不孕症|抗衰老|保护皮肤","rxotc":"otc","Popularity":14,"SaleCount":79,"Title":"双鲸 维生素E软胶囊（天然型）","PromotionLevel":1,"Unit":"","ItemID":"70355","GeneralId":"70355","IconImg":"","Adv":"丹桂十月：低至33元/盒，用于心、脑血管疾病及习惯性流产，不孕症的辅助治疗。","Price":33.0,"ProducerName":"双鲸 维生素E软胶囊（天然型） 100mg*60粒","Price_Market":45.0,"Spec":"100mg*60粒","Domain":"http://m.360kad.com","CommonName":"维生素E软胶囊（天然型）"},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f1D%2f9C%2fCgAgEVal03yAE7FQAAAgAJDIEaU47.jpeg","Keyword":"维生素E软胶囊|心脑血管疾病|习惯性流产|不孕症","rxotc":"otc","Popularity":0,"SaleCount":0,"Title":"舍灵 维生素E软胶囊(天然型)","PromotionLevel":1,"Unit":"","ItemID":"39898","GeneralId":"39898","IconImg":"","Adv":"丹桂十月：低至27元/盒！，可抗衰老、保护皮肤、还能增加卵巢功能，防止习惯性流产。用于心、脑血管疾病及不孕症的辅助治疗。","Price":27.0,"ProducerName":"舍灵 维生素E软胶囊(天然型) 100mg*30粒","Price_Market":35.0,"Spec":"100mg*15粒*2板","Domain":"http://m.360kad.com","CommonName":"维生素E软胶囊(天然型)"},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f1F%2f9D%2fCgAgEVbQYNaAO-AyAAHaiZgLqt8640.jpg_180x180.jpg","Keyword":"来益牌|天然维生素E软胶囊","rxotc":"otc","Popularity":34,"SaleCount":47,"Title":"来益牌 天然维生素E软胶囊","PromotionLevel":1,"Unit":"","ItemID":"74865","GeneralId":"74865","IconImg":"","Adv":"【10月聚惠】低至100元/瓶！本品保健功能是抗氧化、祛黄褐斑。","Price":108.0,"ProducerName":"来益牌 天然维生素E软胶囊 0.4g*160粒","Price_Market":156.0,"Spec":"0.4g*160粒","Domain":"http://m.360kad.com","CommonName":"天然维生素E软胶囊"},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f1F%2fA6%2fCgAgEVbQa-aATWlzAAF8VuEQQIM712.jpg_180x180.jpg","Keyword":"康恩贝|天然维生素E软胶囊|康恩贝 天然维生素E软胶囊","rxotc":"otc","Popularity":7,"SaleCount":1,"Title":"康恩贝 天然维生素E软胶囊","PromotionLevel":1,"Unit":"","ItemID":"1010170240","GeneralId":"1010170240","IconImg":"","Adv":"【十月特惠】低至52元/盒！维生素E可祛斑延缓衰老，满200元还可获价值56元皇后 片仔癀保湿滋润蜜 90ml哦，片仔癀老品牌，滋润水密葆青春！","Price":55.3,"ProducerName":"康恩贝 天然维生素E软胶囊  0.45g*120粒","Price_Market":73.0,"Spec":"0.45g*120粒","Domain":"http://m.360kad.com","CommonName":"天然维生素E软胶囊"},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f1F%2f9D%2fCgAgEFbQXuSAKQu7AAFR2X8XPUA481.jpg_180x180.jpg","Keyword":"养生堂天然维生素E软胶囊|养生堂|天然维生素E|维生素E|1111|11.11|双十一","rxotc":"otc","Popularity":31,"SaleCount":285,"Title":"养生堂 天然维生素E软胶囊","PromotionLevel":4,"Unit":"","ItemID":"41282","GeneralId":"41282","IconImg":"","Adv":"【今日秒杀】仅需109元/瓶，去黄褐斑，美容养颜只需每日一片！满200元还可获价值56元皇后 片仔癀保湿滋润蜜哦，片仔癀老品牌，滋润水密葆青春！","Price":118.0,"ProducerName":"养生堂 天然维生素E软胶囊 160粒","Price_Market":148.0,"Spec":"160粒","Domain":"http://m.360kad.com","CommonName":"天然维生素E软胶囊"},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f3E%2fBE%2fCgAgEVeN2xqAPJOFAAGvQ3fDwqY560.jpg_180x180.jpg","Keyword":"康富来|天然维生素E软胶囊|维生素E","rxotc":"otc","Popularity":0,"SaleCount":0,"Title":"康富来 天然维生素E软胶囊","PromotionLevel":1,"Unit":"","ItemID":"6634","GeneralId":"6634","IconImg":"","Adv":"【十月特惠·秋季滋补礼】原价168，限时特惠79，送康富来 血尔口服液 76ml*2。【女为悦己者容】美如冠玉，倾国倾城~天然VE，是爱美人士之选！","Price":168.0,"ProducerName":"康富来 天然维生素E软胶囊 0.25g*160粒","Price_Market":0,"Spec":"0.25g*160粒","Domain":"http://m.360kad.com","CommonName":"康富来天然维生素E软胶囊"},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f3D%2fD5%2fCgAgEVeIwM-AI1QPAAHR_vt0bAA391.jpg_180x180.jpg","Keyword":"汤臣倍健|天然维生素E软胶囊|皮肤粗糙|缺乏弹性|色斑多|内分泌失调|月经不调|心烦失眠","rxotc":"otc","Popularity":8,"SaleCount":1,"Title":"汤臣倍健 天然维生素E软胶囊（促销装）","PromotionLevel":1,"Unit":"","ItemID":"1010239980","GeneralId":"1010239980","IconImg":"","Adv":"【十月特惠】低至100元/盒，120粒，一天不到1块钱，超值实惠！","Price":118.0,"ProducerName":"汤臣倍健 天然维生素E软胶囊（促销装） 500mg/粒*60粒*2瓶","Price_Market":156.0,"Spec":"500mg/粒*60粒*2瓶","Domain":"http://m.360kad.com","CommonName":"天然维生素E软胶囊（促销装）"},{"ProductThumb":"?url=http%3a%2f%2fimage.360kad.com%2fgroup1%2fM00%2f3D%2fB3%2fCgAgEVeISHqAS_p1AAGLqgbxu8k826.jpg_180x180.jpg","Keyword":"汤臣倍健|番茄红素维生素E软胶囊","rxotc":"otc","Popularity":31,"SaleCount":20,"Title":"汤臣倍健 番茄红素维生素E软胶囊","PromotionLevel":1,"Unit":"","ItemID":"79645","GeneralId":"79645","IconImg":"","Adv":"【本月活动】低至230元起！番茄红素具有抗氧化的作用，常用于前列腺疾病的预防以及保健。","Price":242.0,"ProducerName":"汤臣倍健 番茄红素维生素E软胶囊 500mg/粒*60粒/瓶","Price_Market":321.6,"Spec":"500mg/粒*60粒/瓶","Domain":"http://m.360kad.com","CommonName":"番茄红素维生素E软胶囊"}]}
//		String searchKeyword = "维生素e软胶囊";
//		String url = "http://app.360kad.com/search/default?pageText="+searchKeyword;
//		HttpUtils httpClientUtils = HttpUtils.getInstance();
//		String result = httpClientUtils.sendHttpGet(url);
//		JSONObject searchObj =  JSON.parseObject(result);
//		//Message
//		System.out.println(result);
//		String total = searchObj.getJSONObject("Data").getInteger("total").toString();
//		System.out.println(total);
//		List<String> list = Lists.newArrayList();
//		for(int i=0;i<200;i++){
//			list.add("维生素e软胶囊");
//		}
//		List<Map<String,String>> list2 = threadGet(list);
//		for(Map<String,String> map:list2){
//			System.out.println(map.get("key")+" "+map.get("value"));
//		}
//		
//	}
}
